package com.airnewslinkosky.ticket.net.type;

import java.util.List;

import com.airnewslinkosky.ticket.model.AddressInfo;
import com.airnewslinkosky.ticket.model.PassengerInfo;

public class RequestPassengerInfo {
	/** AS编码 */
	public String asID;
	/** 时间戳，当前接口调用时间 */
	public String timeStamp;
	/** 登录密码 */
	public String userSign;
	/** 授权码 */
	public String officeSign;
	/** 操作类型 */
	public String operateType;
	/** asToken */
	public String asToken;
	
	/** 乘客信息编号 */
	public String passengerNo = "";
	
	public String getRequestData(List<PassengerInfo> passengerInfoList){
		StringBuffer sb = new StringBuffer();
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
		sb.append("<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:coa='http://COA.airnew.com'>")
		  .append("<soapenv:Header/>")
		  .append("<soapenv:Body>")
		  .append(" <coa:PassengerInfoManage2B>")
		  .append(" <coa:ASID>").append(this.asID).append("</coa:ASID>")
		  .append(" <coa:TimeStamp>").append(this.timeStamp).append("</coa:TimeStamp>")
		  .append(" <coa:OfficeSign>").append(this.officeSign).append("</coa:OfficeSign>")
		  .append(" <coa:UserSign>").append(this.userSign).append("</coa:UserSign>")
		  .append(" <coa:ASToken>").append(this.asToken).append("</coa:ASToken>")
		  .append(" <coa:OperateType>").append(this.operateType).append("</coa:OperateType>")
		  .append(" <coa:PassengerName></coa:PassengerName>")
		  .append(" <coa:IDNo></coa:IDNo>")
		  .append(" <coa:Mobile></coa:Mobile>")
		  .append(" <coa:CustomerNo></coa:CustomerNo>")
		  .append(" <coa:PassengerInfos>");
		  for(PassengerInfo passengerInfo:passengerInfoList){
			  passengerNo = passengerInfo.PassengerNo == null ? "" : passengerInfo.PassengerNo;
			 sb.append("<coa:PassengerInfo>")
			  .append(" <coa:PassengerNo>").append(passengerInfo.PassengerNo == null ? "" : passengerInfo.PassengerNo).append("</coa:PassengerNo>")
			  .append(" <coa:PassengerName>").append(passengerInfo.PassengerName == null ? "" : passengerInfo.PassengerName).append("</coa:PassengerName>")
			  .append(" <coa:PassengerType>").append(passengerInfo.PassengerType == null ? "0" : passengerInfo.PassengerType).append("</coa:PassengerType>")
			  .append(" <coa:IDType>").append(passengerInfo.IDType == null ? "0" : passengerInfo.IDType).append("</coa:IDType>")
			  .append(" <coa:IDNo>").append(passengerInfo.IDNo == null ? "" : passengerInfo.IDNo).append("</coa:IDNo>")
			  .append(" <coa:PassengerMobile>").append(passengerInfo.PassengerMobile == null ? "" : passengerInfo.PassengerMobile).append("</coa:PassengerMobile>")
			  .append(" <coa:Birthday>").append(passengerInfo.Birthday == null ? "" : passengerInfo.Birthday).append("</coa:Birthday>")
			  .append(" <coa:PassengerLevel>").append(passengerInfo.PassengerLevel == null ? "" : passengerInfo.PassengerLevel).append("</coa:PassengerLevel>")
			  .append(" <coa:PassengerState>").append(passengerInfo.PassengerState == null ? "" : passengerInfo.PassengerState).append("</coa:PassengerState>")
			  .append(" <coa:Remark>").append(passengerInfo.Remark == null ? "" : passengerInfo.Remark).append("</coa:Remark>");
			  if(passengerInfo.addressInfoList != null){
			  sb.append(" <coa:AddressInfos>");
			  for(AddressInfo addressInfo : passengerInfo.addressInfoList){
				sb.append(" <coa:AddressInfo>")
				  .append(" <coa:PostAddress>").append(addressInfo.PostAddress == null ? "" : addressInfo.PostAddress).append("</coa:PostAddress>")
				  .append(" <coa:AddressNo>").append(addressInfo.AddressNo == null ? "" : addressInfo.AddressNo).append("</coa:AddressNo>")
				  .append(" <coa:PassengerNo>").append(addressInfo.PassengerNo == null ? "" : addressInfo.PassengerNo).append("</coa:PassengerNo>")
				  .append(" <coa:PostName>").append(addressInfo.PostName == null ? "" : addressInfo.PostName).append("</coa:PostName>")
				  .append(" <coa:Phone>").append(addressInfo.Phone == null ? "" : addressInfo.Phone).append("</coa:Phone>")
				  .append(" <coa:ZIP>").append(addressInfo.ZIP == null ? "" : addressInfo.ZIP).append("</coa:ZIP>")
				  .append(" </coa:AddressInfo>");
			  }
			  sb.append(" </coa:AddressInfos>");
			  }
			  sb.append(" <coa:CustomerNo>").append(passengerInfo.CustomerNo == null ? "" : passengerInfo.CustomerNo).append("</coa:CustomerNo>");
			  sb.append(" <coa:Email>").append(passengerInfo.Email == null ? "" : passengerInfo.Email).append("</coa:Email>");
			  sb.append(" <coa:PassengerNo>").append(this.passengerNo == null ? "" : this.passengerNo).append("</coa:PassengerNo>");
			  sb.append(" </coa:PassengerInfo>");
		  }
		  sb.append(" </coa:PassengerInfos>")
		  .append("  </coa:PassengerInfoManage2B>")
		  .append(" </soapenv:Body>")
		  .append(" </soapenv:Envelope>");
		                     
		return sb.toString();
	}
}
